﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.Domain.Query.Message
{
    public class MessageDetailQuery
    {
        public long? FromUser { get; set; } = null;
        /// <summary>
        /// 不等于
        /// </summary>
        public long? FromUserNE { get; set; } = null;

        public long? ToUser { get; set; } = null;
        public long? ToUserNE { get; set; } = null;

        public string IsDelete { get; set; } = string.Empty;
        public string IsOpen { get; set; } = string.Empty;

        /*************可以进行模糊查询的条件***********************/

        /// <summary>
        /// 模糊查询
        /// </summary>
        public bool FuzzyQuery { get; set; } = false;

        /// <summary>
        /// 查询表达式
        /// </summary>
        /// <returns></returns>
        public Expression<Func<furion.blog.Domain.MySQL.Message, bool>> Exp()
        {
            var exp = Expressionable.Create<furion.blog.Domain.MySQL.Message>();
            exp.AndIF(FromUser != null, t => t.FromUser == FromUser);
            exp.AndIF(FromUserNE != null, t => t.FromUser != FromUserNE);
            exp.AndIF(ToUser != null, t => t.ToUser == ToUser);
            exp.AndIF(ToUserNE != null, t => t.ToUser != ToUserNE);
            exp.AndIF(!string.IsNullOrWhiteSpace(IsDelete),t=>t.IsDelete == IsDelete);
            exp.AndIF(!string.IsNullOrWhiteSpace(IsOpen), t => t.IsOpen == IsOpen);

            if (!FuzzyQuery)
            {
                
            }
            else
            {
               
            }
            return exp.ToExpression();
        }
    }
}
